﻿namespace CL_Searcher.Classes
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Windows.Controls;
    using System.Xml;
    using System.Xml.Serialization;

    public class Configuration
    {
        public Configuration(ObservableCollection<SearchQuery> searchQueries, SearchQuery selectedSearchQuery, ObservableCollection<Country> locations, ObservableCollection<Category> categories, ObservableCollection<City> selectedLocations, Settings settings, List<string> hiddenPosts)
        {
            SearchQueries = searchQueries;
            SelectedSearchQuery = selectedSearchQuery;
            Locations = locations;
            Categories = categories;
            SelectedLocations = selectedLocations;
            Settings = settings;
            HiddenPosts = hiddenPosts;
        }

        public Configuration()
        {
        }

        public ObservableCollection<SearchQuery> SearchQueries { get; set; }

        [System.Xml.Serialization.XmlIgnore]
        public SearchQuery SelectedSearchQuery { get; set; }
        
        [System.Xml.Serialization.XmlIgnore]
        public ObservableCollection<Country> Locations { get; set; }
        
        [System.Xml.Serialization.XmlIgnore]
        public ObservableCollection<Category> Categories { get; set; }
        
        public ObservableCollection<City> SelectedLocations { get; set; }

        public Settings Settings { get; set; }

        public List<string> HiddenPosts { get; set; }
    }

    public class Category
    {
        public Category(string code, string description)
        {
            Code = code;
            Description = description;
        }

        public Category()
        {
        }

        public string Code { get; set; }

        public string Description { get; set; }
    }

    public class City
    {
        public City(string url, string name)
        {
            Url = url;
            Name = name;
        }

        public City()
        {
        }

        public string Url { get; set; }

        public string Name { get; set; }
    }

    public class Region
    {
        public Region(string name, ObservableCollection<City> cities)
        {
            Name = name;
            Cities = cities;
        }

        public Region()
        {
        }

        public string Name { get; set; }

        public ObservableCollection<City> Cities { get; set; }
    }

    public class Country
    {
        public Country(string name, ObservableCollection<Region> regions)
        {
            Name = name;
            Regions = regions;
        }

        public Country()
        {
        }

        public string Name { get; set; }

        public ObservableCollection<Region> Regions { get; set; }
    }

    public class SearchQuery
    {
        public SearchQuery(string query, Category category, string categoryDescription, int minPrice, int maxPrice, bool hasImage, bool titleTonly, ObservableCollection<City> locations, DateTime lastSearchTime, ObservableCollection<Post> posts)
        {
            Query = query;
            Category = category;
            CategoryDescription = categoryDescription;
            MinPrice = minPrice;
            MaxPrice = maxPrice;
            HasImage = hasImage;
            TitleOnly = titleTonly;
            Locations = locations;
            LastSearchTime = lastSearchTime;
            Posts = posts;
        }

        public SearchQuery()
        {
        }

        public string Query { get; set; }

        public Category Category { get; set; }

        public string CategoryDescription { get; set; }

        public int MinPrice { get; set; }

        public int MaxPrice { get; set; }

        public bool HasImage { get; set; }

        public bool TitleOnly { get; set; }

        public ObservableCollection<City> Locations { get; set; }

        public DateTime LastSearchTime { get; set; }
        
        [System.Xml.Serialization.XmlIgnore]
        public ObservableCollection<Post> Posts { get; set; }
    }

    public class Post
    {
        public Post(string title, string link, string description, DateTime date, int price)
        {
            Title = title;
            Link = link;
            Description = description;
            Date = date;
            Price = price;
        }

        public Post()
        {
        }

        public string Title { get; set; }

        public string Link { get; set; }

        public string Description { get; set; }

        public DateTime Date { get; set; }

        public int Price { get; set; }
    }

    public class Settings
    {
        public Settings(string emailServer, string emailPort, bool emailUseSSL, string emailUsername, string emailPassword, string emailFromAddress, string emailToAddress, bool emailNewPosts)
        {
            EmailServer = emailServer;
            EmailPort = emailPort;
            EmailUseSSL = emailUseSSL;
            EmailUsername = emailUsername;
            EmailPassword = emailPassword;
            EmailFromAddress = emailFromAddress;
            EmailToAddress = emailToAddress;
            EmailFromAddress = emailFromAddress;
            EmailNewPosts = emailNewPosts;
        }

        public Settings()
        {
        }

        public string EmailServer { get; set; }

        public string EmailPort { get; set; }

        public bool EmailUseSSL { get; set; }

        public string EmailUsername { get; set; }

        public string EmailPassword { get; set; }

        public string EmailFromAddress { get; set; }

        public string EmailToAddress { get; set; }

        public bool EmailNewPosts { get; set; }
    }
}